<template>
    <div class="act-box">
      <div class="nav">
        <div @click="sear()" class="nav2">
          <input type="text" placeholder="search">
          <img :src="'./static/lyl/search.png'" alt="">
        </div>
        <span @click="searD()">搜索</span>
      </div>

      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="(item,index) in swiperimg" :key="index">
            <img :src="item" alt="">
          </div>
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination"></div>
      </div>

      <ul class="ultwo">
        <li v-for="(item,index) in dataty" :key="index" @click="actdel(item)">
          <div class="li-top">
            <img :src="item.main_pic" alt="">
            <span>{{item.apply}}</span>
            <span v-if="item.is_rec==0?false:true">推荐</span>
          </div>
          <p>{{item.title}}</p>
        </li>
      </ul>

      <Footer></Footer>
    </div>
</template>

<script>
  import Swiper from 'swiper'
  //import {Dialog} from 'vant';
  import Footer from '../../com/Footer'
  import * as home from "../../../api/home.js";
  //import * as list from "../../../api/list.js";
    export default {
      name: "Active",
      data(){
        return {
          dataty:[],
          swiperimg:[],
        }
      },
      beforeMount(){
        let parmes = {type:1};
        home.bannerList(parmes).then(res=>{
          this.swiperimg = res.data;
          this.$nextTick(() => {  // 下一个UI帧再初始化swiper
            var swiper = new Swiper('.swiper-container', {
              autoplay:true,
              loop : true,
              pagination: {
                el: '.swiper-pagination',
              },
            });
          })
        });

        home.activeList().then(res=>{
          this.dataty = res.data;
        })
      },
      // mounted(){
      //   // //首页返回键处理
      //   // //处理逻辑：1秒内，连续两次按返回键，则退出应用；
      //   var first = null;
      //   mui.back = function() {
      //     //首次按键，提示  再按一次退出应用
      //     if (!first) {
      //       first = new Date().getTime();//记录第一次按下回退键的时间
      //       mui.toast('再按一次退出应用');//给出提示
      //       history.go(-1)//回退到上一页面
      //       setTimeout(function() {//1s中后清除
      //         first = null;
      //       }, 1000);
      //     } else {
      //       if (new Date().getTime() - first < 1000) {//如果两次按下的时间小于1s，
      //         plus.runtime.quit();//那么就退出app
      //
      //       } } };
      // },
      components:{
        Footer
      },
      methods:{
        sear(){
          this.$router.push('/searchhistory');
        },
        actdel(item){
          this.$router.push({path:'/active2/0/'+item.id});
        },
        searD(){
          this.$router.push('/synthesize/0')
        },
        // activity(){
        //   if (this.$store.state.user_id.length==0) {
        //     this.$router.push('/register')
        //   }else{
        //     let parms = {user_id:this.$store.state.user_id};
        //     list.isAuth(parms).then(res=>{
        //       if (res.data.is_auth==0){
        //         Dialog.confirm({
        //           title:'你还没认证，不能发起活动',
        //           message: "是否前往认证？"
        //         }).then(()=>{
        //           this.$router.push('/myRealRadio');
        //         });
        //       } else{
        //         this.$router.push('/activity');
        //       }
        //     });
        //   }
        // }
      }
    }
</script>

<style scoped>
  .act-box{
    padding:100px 0 130px;
  }
  .nav{
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    z-index: 999;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    background: #884ca4;
    padding: 20px 40px;
    /*margin-bottom: 20px;*/
  }
  .nav>span{
    font-size: 32px;
    color: #fff;
    align-self: center;
    letter-spacing: 4px;
  }
  .nav2{
    flex-grow: 1;
    padding-right: 40px;
    position: relative;
  }
  input{
    -webkit-box-sizing:border-box;
    box-sizing: border-box;
    width: 100%;
    padding: 13px 0 13px 82px;
    font-size: 28px;
    color: #8c8c8c;
    border-radius: 10px;
  }
  .nav2 img{
    position: absolute;
    left: 23px;
    top: 13px;
    width: 32px;
  }

  .ultwo{
    padding: 20px 40px;
  }
  .ultwo li{
    position: relative;
    border-radius: 20px;
    background: #e7c7fd;
    margin-bottom: 30px;
    overflow: hidden;
  }
  .ultwo li .li-top{
    position: relative;
    height: 400px;
  }
  .ultwo li .li-top img{
    width: 100%;
    height: 100%;
  }
  .ultwo li .li-top span{
    position: absolute;
    left: 20px;
    top: 20px;
    display: inline-block;
    cursor: pointer;
  }
  .ultwo li .li-top span:nth-child(2){
    position: absolute;
    right: 20px;
    top: 20px;
    width: 90px;
    height: 40px;
    border-radius: 20px;
    text-align: center;
    line-height: 40px;
    background: #ff6174;
    color: #fff;
  }
  .ultwo li .li-top span:nth-child(3){
    width: 52px;
    height: 63px;
    background: url("/static/lyl/recom.png") no-repeat center/cover;
    font-size: 24px;
    color: #fff;
    float: right;
    text-align: center;
  }
  .ultwo li p{
    position: absolute;
    left: 0;
    bottom: 0;
    box-sizing: border-box;
    width: 100%;
    font-size: 24px;
    color: #fff;
    padding: 13px 0 10px 20px;
    background: rgba(0,0,0,0.7);
  }
</style>
